package com.boot.stomp.service;

import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @description Stomp 消息生产者 TODO: 目前没有业务
 * @date 2021/8/2 23:27
 **/

public class DefaultStompSupplierService<T> {

    private final StreamBridge streamBridge;
    private final static String BINDING_NAME = "stomp_supplier_service-out-0";

    public DefaultStompSupplierService(StreamBridge streamBridge) {
        this.streamBridge = streamBridge;
    }

    public void send(T payload) {
        Message<T> message = MessageBuilder.withPayload(payload).build();
        streamBridge.send(BINDING_NAME, message);
    }
}
